package priv.yiyuan.example.design.flyweight;

/**
 * 满减价格计算策略
 * <p>
 * 享元模式-具体享元
 * 策略模式-具体策略
 *
 * @author YiYuan
 * @data 2025/9/19
 * @apoNote
 */
public class FullReductionStrategy implements PriceCalculationStrategy {

    private double fullAmount;

    private double reductionAmount;

    public FullReductionStrategy(double fullAmount, double reductionAmount) {
        this.fullAmount = fullAmount;
        this.reductionAmount = reductionAmount;
        System.out.println("创建新的满减策略享元: 满" + fullAmount + " 减 " + reductionAmount);
    }

    @Override
    public double calculatePrice(double originalPrice) {

        if (originalPrice >= fullAmount) {
            return originalPrice - reductionAmount;
        }

        return originalPrice;
    }
}
